<?php

class DeleteAction extends CAction
{
    public function run()
    {
        if(!isset($_POST['id']))
            throw new CHttpException(400,'The requested is invalid.');
                    
        $comment=Comment::loadObjectById($_POST['id']);
        if($comment===null)
            throw new CHttpException(404,'The requested comment does not exist.');
        if($comment->userId!==Yii::app()->user->id)
            throw new CHttpException(403,'The requested comment does not belong to you');
        
        $succ = Comment::deleteObject($comment);
        $this->controller->renderPartial('/common/json',array(
            'data'=>array(
                'succ'=>$succ,
                'error'=>'系统错误',
        )));        
    }
}
  
?>